package com.beer.beerfriendfinder.model;

import org.json.JSONObject;

public class Users {
	private int _id;
	private String email;
	private String phoneNumber;
	private String birthday;
	private String position;
	private String created_at;
	
	public Users(int id, String mail, String phone, String birth , String pos , String create){
		_id = id ;
		email = mail;
		phoneNumber = phone;
		birthday = birth;
		position = pos;
		created_at = create;
	}
	
	public Users(int id , String mail){
		this(id,mail,"","","","");
	}
	
	public Users(JSONObject jsonObject){
		try{
			_id = jsonObject.getInt("id");
		}catch(Exception e){
			
		}
		try{
			email = jsonObject.getString("email");
		}catch(Exception e){
			
		}
		try{
			phoneNumber = jsonObject.getString("phoneNumber");
		}catch(Exception e){
			
		}
		try{
			birthday = jsonObject.getString("birthday");
		}catch(Exception e){
			
		}
		try{
			position = jsonObject.getString("position");
		}catch(Exception e){
			
		}
		try{
			created_at = jsonObject.getString("created_at");
		}catch(Exception e){
			
		}
	}

	public int get_id() {
		return _id;
	}

	public void set_id(int _id) {
		this._id = _id;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getBirthday() {
		return birthday;
	}

	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	public String getPosition() {
		return position;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public String getCreated_at() {
		return created_at;
	}

	public void setCreated_at(String created_at) {
		this.created_at = created_at;
	}
	
	public String toJSONObject(){
		String result= "";
		try{
			JSONObject jsonObject = new JSONObject();
			jsonObject.put("id", _id);
			jsonObject.put("email", email);
			jsonObject.put("phoneNumber", phoneNumber);
			jsonObject.put("position", position);
			jsonObject.put("birthday", birthday);
			jsonObject.put("created_at", created_at);
			result = jsonObject.toString();
		}catch(Exception e){
			
		}
		
		return result;
	}
	
}
